package cn.itcast.controller.stat;

import cn.itcast.controller.BaseController;
import cn.itcast.service.stat.StatService;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/stat")
public class StatController extends BaseController {

    @Reference
    private StatService statService;

    @RequestMapping(value = "/toCharts",name = "跳转到显示图表报表页面")
    public String toCharts(String chartsType){  //sell  factory  online


        return "/stat/stat-"+chartsType;
    }

    /*[
            {value: 335, name: '直接访问'},
            {value: 310, name: '邮件营销'},
            {value: 234, name: '联盟广告'},
            {value: 135, name: '视频广告'},
            {value: 1548, name: '搜索引擎'}
    ]*/
    @RequestMapping(value = "/factoryCharts",name = "每个厂家的销售金额统计")
    @ResponseBody
    public List<Map> factoryCharts(){  //sell  factory  online

        return  statService.factoryCharts(getCompanyId());
    }
    @RequestMapping(value = "/sellCharts",name = "每个产品的销售量统计")
    @ResponseBody
    public List<Map> sellCharts(){  //sell  factory  online

        return  statService.sellCharts(getCompanyId());
    }
    @RequestMapping(value = "/onlineCharts",name = "24小时系统访问压力统计")
    @ResponseBody
    public List<Map> onlineCharts(){  //sell  factory  online

        return  statService.onlineCharts(getCompanyId());
    }



}
